﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace job
{
    public partial class admin2_add : Form
    {
        public admin2_add()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {

            if (textBox1sno.Text != "" && textBox2name.Text!= "" && textBox3major.Text != "" && textBox4number.Text != "" && textBox5goto.Text != "")
            {
                Dao dao = new Dao();
                string sql = $"insert into student_news values ('{textBox1sno.Text}','{textBox2name.Text}','{textBox3major.Text}',{textBox4number.Text},'{textBox5goto.Text}')";                
                int n = dao.Execute(sql);//添加的值传回dao
                if (n > 0)
                {
                    MessageBox.Show("添加成功");

                }
                else
                {
                    MessageBox.Show("添加失败");
                }
                textBox1sno.Text = ""; //增加后清空文本框
                textBox2name.Text = "";
                textBox3major.Text = "";
                textBox4number.Text = "";
                textBox5goto.Text = "";


            }
            else
            {
                MessageBox.Show("你的输入有空，请重新输入");
            }

        }

        private void button2_Click(object sender, EventArgs e)
        {
            admin2_add admin = new admin2_add();
            this.Close();
        }
    }
}
